package cn.lisens.demo.views;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.document.AbstractPdfView;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;

public class PdfView extends AbstractPdfView {

	@Override
	protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		BaseFont font = BaseFont.createFont("STSong-Light",  "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
		Font chinese = new Font(font,12);
		List<String> words = (List<String>) model.get("wordList");
		for (String word : words) {
			document.add(new Paragraph(word,chinese));
		}
//		response.setHeader("Content-disposition", "attachment; FILENAME=someName.pdf");
	}

}
